/**
 * 图片参数处理函数
 */
var picParameter = function () {
    var picPropertity;
    return {
        init: function () {

        },
        /**
         * 获取车辆小图(定位，小面板,车辆瀑布流)
         */
        getVehicleMinPic: function (ssid, w, h) {
            picPropertity = {
                ssid: ssid,
                field: "STORAGE_URL1",
                type: "MOTOR_VEHICLE",
                original: "0",
                rect: "0",
                width: "0"
            };
            if (w) {
                picPropertity.width = w;
            }
            if (h) {
                picPropertity.height = h;
            }
            return picPropertity;
        },
        /**
         * 获取车辆大图(车辆详细信息)
         */
        getVehicleMaxPic: function (ssid) {
            picPropertity = {
                ssid: ssid,
                field: "STORAGE_URL3",
                type: "MOTOR_VEHICLE",
                original: "0",
                rect: "0",
                width: "0"
            };
            return picPropertity;
        },
        /**
         * 获取人员小图(人员瀑布流)
         */
        getPersonMinPic: function (ssid) {
            picPropertity = {
                ssid: ssid,
                field: "PERSON_PHOTOS",
                type: "PERSON",
                original: "0",
                rect: "0",
                width: "0"
            };
            return picPropertity;
        },
        /**
         * 获取人员大图(人员详细信息)
         */
        getPersonMaxPic: function (ssid) {
            picPropertity = {
                ssid: ssid,
                field: "PANORAMA_PHOTOS",
                type: "PERSON",
                original: "0",
                rect: "1",
                width: "0"
            };
            return picPropertity;
        },
        /**
         * 获取主驾、副驾人脸图
         * @param ssid
         * @param type   "FACE"
         * @returns {{ssid: *, field: string, type: *, original: string, rect: string, width: string}|*}
         */
        getFaceMinPic: function (ssid, type) {
            picPropertity = {
                ssid: ssid,
                field: "FACE_PHOTOS",
                type: type,
                original: "0",
                rect: "0",
                width: "0"
            };
            return picPropertity;
        },
    }
}();
picParameter.init();

/**
 * dropdown多选组件
 *
 * @author 陈明松
 */
var dropdownCheckbox = function () {
    /**
     * 初始化html
     *
     * @param classType 要启用该下拉多选功能的dom的class
     * @param  checkBoxHtml 复选框选项html
     */
    var initHtml = function (classType, checkBoxHtml, tt) {
        var dropdownCheckBoxArr = $('.' + classType);
        $.each(dropdownCheckBoxArr, function (i, d) {
            $(d).attr("data-toggle", "dropdown");
            var html = '' +
                '                   <div class="dropdown dropdown-checkbox-all">';
            html += $(d).prop("outerHTML");//获取自身html
            html +=
                '   <i class="fa fa-close hide-search" id="public_input_delete" onclick="' + tt + '" ' +
                '   style="cursor: pointer;color: #dddddd;margin-top: 11px;margin-left: -20px;"></i>' +
                '                    <div class="dropdown-menu dropdown-menu-left dropdown-checkbox-body">' +
                '                            <div class="dropdown-checkbox-input-all">';
            html += checkBoxHtml;//选项的html
            html += '                        </div>' +
                '                        </div>' +
                '                    </div>';
            $(d).replaceWith(html);//替换自身元素
        });
    };
    /**
     * 初始化布局
     */
    var initLayout = function () {
        var dropdownCheckBoxBodyArr = $('.dropdown-checkbox-body');
        $.each(dropdownCheckBoxBodyArr, function (i, d) {
            //宽度
            // $(d).width($(d).prev().width() + 10);/**zhoukh 注释本行*/
            //阻止冒泡
            $(d).click(function (e) {
                e.stopPropagation();
            });
        })
    }
    return {
        /**
         *
         * @param checkBoxHtml 复选框选项的html
         */
        init: function (classType, checkBoxHtml) {
            initHtml(classType, checkBoxHtml);
            initLayout();
        },
    }
}();


/**
 * 号牌种类公共组件
 *
 * 在class中添加“public-plate-class-type”即可使用
 *
 * 获取值：publicPlateClassType.getValue(dom);
 *
 * @author 陈明松
 */
var publicPlateClassType = function () {
    //标识为要使用号牌种类的公共组件
    var classType = "public-plate-class-type";
    //选中项的class
    var checkClass = "layui-form-checked";
    //【全部】选项的class
    var allClass = 'dropdown-checkbox-selectAll';
    //复选框选项html
    var checkBoxHtml = '' +
        '<div class="layui-unselect layui-form-checkbox ' + allClass + '" lay-skin="primary" onclick="publicPlateClassType.selectAll(this)"><span>全部</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="02" onclick="publicPlateClassType.selectOne(this)" lay-skin="primary"><span>小型汽车号牌</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="01" onclick="publicPlateClassType.selectOne(this)" lay-skin="primary"><span>大型汽车号牌</span><i class="layui-icon"></i></div>' +

        //!!!!!!!!!!!!!!!数据库自动还没有加
        '<div class="layui-unselect layui-form-checkbox" data-value="66" onclick="publicPlateClassType.selectOne(this)" lay-skin="primary"><span>新能源号牌</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="15" onclick="publicPlateClassType.selectOne(this)" lay-skin="primary"><span>挂车号牌</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="37" onclick="publicPlateClassType.selectOne(this)" lay-skin="primary"><span>临时行驶车号牌</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="49" onclick="publicPlateClassType.selectOne(this)" lay-skin="primary"><span>黄色双行尾牌</span><i class="layui-icon"></i>' +
        '';
    return {
        init: function () {
            dropdownCheckbox.init(classType, checkBoxHtml);
        },
        /**
         * 获取已选中的值
         * @param item
         */
        getValue: function (item) {
            var result = [];
            var allChildren = $(item).next().next().children().children();
            $.each(allChildren, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                } else if ($(d).hasClass(checkClass)) {
                    result.push($(d).attr("data-value"));
                }
            });
            $.each(allChildren, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                    if ($(d).hasClass(checkClass)) {
                        result = [];
                    }
                }
            });
            /*  if($(item + " ."+allClass).hasClass(checkClass)){
                  result = [];
              }*/
            return result.toString();
        },
        /**
         * 全选
         */
        selectAll: function (item) {
            var selectAll = true;
            if ($(item).hasClass(checkClass)) {
                $(item).removeClass(checkClass);
                selectAll = false;
            } else {
                $(item).addClass(checkClass);
            }

            var nextAll = $(item).nextAll();
            $.each(nextAll, function (i, d) {
                if (selectAll) {
                    $(d).addClass(checkClass);
                } else {
                    $(d).removeClass(checkClass);
                }
            })
            //刷新提示信息
            publicPlateClassType.refreshInfo(item);
        },
        /**
         * 选中一个
         */
        selectOne: function (item) {
            if ($(item).hasClass(checkClass)) {
                $(item).removeClass(checkClass);
            } else {
                $(item).addClass(checkClass);
            }
            //全选按钮处理
            var selectCount = publicPlateClassType.getSelectCount(item);
            //选中了【全部】以为的所有选项,则将全选选中，不然则取消全选的选中
            var prevAll = $(item).prevAll();
            $.each(prevAll, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    if (selectCount == $(item).siblings().length) {
                        $(d).addClass(checkClass);
                    } else {
                        $(d).removeClass(checkClass);
                    }
                }
            })

            //刷新提示信息
            publicPlateClassType.refreshInfo(item);
        },
        /**
         * 刷新提示信息
         */
        refreshInfo: function (item) {
            var message = '';
            var count = 0;
            //全部选中
            if ($(item).hasClass(allClass) && $(item).hasClass(checkClass)) {
                message = "已全部选中";
            } else {
                var count = publicPlateClassType.getSelectCount(item);
            }
            if (count > 0) {
                message = "已选择 " + count + " 项";
            }
            var inputDom = $(item).parents('.dropdown-checkbox-all').children("." + classType);
            $(inputDom).val(message);
        },
        /**
         * 获取选中了多少个,不包括全部
         * @param item
         */
        getSelectCount: function (item) {
            var count = 0;
            //点击的节点
            if ($(item).hasClass(checkClass)) {
                count++;
            }
            //所有的兄弟节点,不包括全部
            var all = $(item).siblings();
            $.each(all, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                } else if ($(d).hasClass(checkClass)) {
                    count++;
                }
            });
            return count;
        }
    }
}();
publicPlateClassType.init();

/**
 * 假套牌公共组件
 *
 * 在class中添加“public-copy-plate”即可使用
 *
 * 获取值：publicCopyPlateClassType.getValue(dom);
 */
var publicCopyPlateClassType = function () {
    //标识为要使用号牌种类的公共组件
    var classType = "public-copy-plate";
    //选中项的class
    var checkClass = "layui-form-checked";
    //【全部】选项的class
    var allClass = 'dropdown-checkbox-selectAll';
    //复选框选项html
    var checkBoxHtml = '' +
        '<div class="layui-unselect layui-form-checkbox ' + allClass + '" lay-skin="primary" onclick="publicCopyPlateClassType.selectAll(this)"><span>全部</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="0" onclick="publicCopyPlateClassType.selectOne(this)" lay-skin="primary"><span>套牌</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="1" onclick="publicCopyPlateClassType.selectOne(this)" lay-skin="primary"><span>非套牌</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="2" onclick="publicCopyPlateClassType.selectOne(this)" lay-skin="primary"><span>疑似套牌车</span><i class="layui-icon"></i></div>' +
        '';
    return {
        init: function () {
            dropdownCheckbox.init(classType, checkBoxHtml);
        },
        /**
         * 获取已选中的值
         * @param item
         */
        getValue: function (item) {
            var result = [];
            var allChildren = $(item).next().next().children().children();
            $.each(allChildren, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                } else if ($(d).hasClass(checkClass)) {
                    result.push($(d).attr("data-value"));
                }
            });
            $.each(allChildren, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                    if ($(d).hasClass(checkClass)) {
                        result = [];
                    }
                }
            });
            return result.toString();
        },
        /**
         * 全选
         */
        selectAll: function (item) {
            var selectAll = true;
            if ($(item).hasClass(checkClass)) {
                $(item).removeClass(checkClass);
                selectAll = false;
            } else {
                $(item).addClass(checkClass);
            }

            var nextAll = $(item).nextAll();
            $.each(nextAll, function (i, d) {
                if (selectAll) {
                    $(d).addClass(checkClass);
                } else {
                    $(d).removeClass(checkClass);
                }
            })
            //刷新提示信息
            publicCopyPlateClassType.refreshInfo(item);
        },
        /**
         * 选中一个
         */
        selectOne: function (item) {
            if ($(item).hasClass(checkClass)) {
                $(item).removeClass(checkClass);
            } else {
                $(item).addClass(checkClass);
            }
            //全选按钮处理
            var selectCount = publicCopyPlateClassType.getSelectCount(item);
            //选中了【全部】以为的所有选项,则将全选选中，不然则取消全选的选中
            var prevAll = $(item).prevAll();
            $.each(prevAll, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    if (selectCount == $(item).siblings().length) {
                        $(d).addClass(checkClass);
                    } else {
                        $(d).removeClass(checkClass);
                    }
                }
            })

            //刷新提示信息
            publicCopyPlateClassType.refreshInfo(item);
        },
        /**
         * 刷新提示信息
         */
        refreshInfo: function (item) {
            var message = '';
            var count = 0;
            //全部选中
            if ($(item).hasClass(allClass) && $(item).hasClass(checkClass)) {
                message = "已全部选中";
            } else {
                var count = publicCopyPlateClassType.getSelectCount(item);
            }
            if (count > 0) {
                message = "已选择 " + count + " 项";
            }
            var inputDom = $(item).parents('.dropdown-checkbox-all').children("." + classType);
            $(inputDom).val(message);
        },
        /**
         * 获取选中了多少个,不包括全部
         * @param item
         */
        getSelectCount: function (item) {
            var count = 0;
            //点击的节点
            if ($(item).hasClass(checkClass)) {
                count++;
            }
            //所有的兄弟节点,不包括全部
            var all = $(item).siblings();
            $.each(all, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                } else if ($(d).hasClass(checkClass)) {
                    count++;
                }
            });
            return count;
        }
    }
}();
publicCopyPlateClassType.init();

/**
 * 当日出入城配置 车道多选组件
 *
 * 在class中添加“public-plane-no”即可使用
 *
 * 获取值：publicPlaneNo.getValue(dom);
 */
var publicPlaneNo = function () {
    //标识为要使用号牌种类的公共组件
    var classType = "public-plane-no";
    //选中项的class
    var checkClass = "layui-form-checked";
    //【全部】选项的class
    var allClass = 'dropdown-checkbox-selectAll';
    //复选框选项html
    var checkBoxHtml = '' +
        '<div class="layui-unselect layui-form-checkbox hide-search ' + allClass + '" lay-skin="primary" onclick="publicPlaneNo.selectAll(this)"><span>全部</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="1" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道1</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="2" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道2</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="3" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道3</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="4" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道4</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="5" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道5</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="6" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道6</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="7" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道7</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="8" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道8</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="9" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道9</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="10" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道10</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="11" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道11</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="12" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道12</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="13" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道13</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="14" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道14</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="15" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道15</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="16" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道16</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="17" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道17</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="18" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道18</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="19" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道19</span><i class="layui-icon"></i></div>' +
        '<div class="layui-unselect layui-form-checkbox" data-value="20" onclick="publicPlaneNo.selectOne(this)" lay-skin="primary"><span>车道20</span><i class="layui-icon"></i></div>' +
        '';
    return {
        init: function () {
            dropdownCheckbox.init(classType, checkBoxHtml);
            this.deleteAllChose();
        },
        deleteAllChose: function () {
            $("#public_input_delete").on('click', function () {
                $(this).addClass("hide-search");
                $(".public-plane-no").val('');
                var allChildren = $(".public-plane-no").next().next().children().children();
                $.each(allChildren, function (i, d) {
                    if ($(d).hasClass(allClass)) {
                        //点击的是全部
                    } else if ($(d).hasClass(checkClass)) {
                        $(d).removeClass(checkClass);
                    }
                });
            });
        },
        /**
         * 获取已选中的值
         * @param item
         */
        getValue: function (item) {
            var result = [];
            var allChildren = $(item).next().next().children().children();
            $.each(allChildren, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                } else if ($(d).hasClass(checkClass)) {
                    result.push($(d).attr("data-value"));
                }
            });
            $.each(allChildren, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                    if ($(d).hasClass(checkClass)) {
                        result = [];
                    }
                }
            });
            return result.toString();
        },
        /**
         * 全选
         */
        selectAll: function (item) {
            var selectAll = true;
            if ($(item).hasClass(checkClass)) {
                $(item).removeClass(checkClass);
                selectAll = false;
            } else {
                $(item).addClass(checkClass);
            }

            var nextAll = $(item).nextAll();
            $.each(nextAll, function (i, d) {
                if (selectAll) {
                    $(d).addClass(checkClass);
                } else {
                    $(d).removeClass(checkClass);
                }
            })
            //刷新提示信息
            publicPlaneNo.refreshInfo(item);
        },
        /**
         * 选中一个
         */
        selectOne: function (item) {
            if ($(item).hasClass(checkClass)) {
                $(item).removeClass(checkClass);
            } else {
                $(item).addClass(checkClass);
            }
            //全选按钮处理
            var selectCount = publicPlaneNo.getSelectCount(item);
            //选中了【全部】以为的所有选项,则将全选选中，不然则取消全选的选中
            var prevAll = $(item).prevAll();
            $.each(prevAll, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    if (selectCount == $(item).siblings().length) {
                        $(d).addClass(checkClass);
                    } else {
                        $(d).removeClass(checkClass);
                    }
                }
            })

            //刷新提示信息
            publicPlaneNo.refreshInfo(item);
        },
        /**
         * 刷新提示信息
         */
        refreshInfo: function (item) {
            var message = '';
            var count = 0;
            var flag = 0;
            //全部选中
            if ($(item).hasClass(allClass) && $(item).hasClass(checkClass)) {
                message = "已全部选中";
                flag = 1;
            } else {
                var count = publicPlaneNo.getSelectCount(item);
            }
            if (count > 0) {
                $(".mulitDataCopyPlate .dropdown  #public_input_delete").removeClass("hide-search");
                message = "已选择 " + count + " 项";
            } else {
                if (flag == 0) {
                    $(".mulitDataCopyPlate .dropdown  #public_input_delete").addClass("hide-search");
                } else {
                    $(".mulitDataCopyPlate .dropdown  #public_input_delete").removeClass("hide-search");
                }
            }
            var inputDom = $(item).parents('.dropdown-checkbox-all').children("." + classType);
            $(inputDom).val(message);
        },
        /**
         * 获取选中了多少个,不包括全部
         * @param item
         */
        getSelectCount: function (item) {
            var count = 0;
            //点击的节点
            if ($(item).hasClass(checkClass)) {
                count++;
            }
            //所有的兄弟节点,不包括全部
            var all = $(item).siblings();
            $.each(all, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                } else if ($(d).hasClass(checkClass)) {
                    count++;
                }
            });
            return count;
        }
    }
}();
publicPlaneNo.init();
/**
 * 公共返回页面，查询不到结果时默认展示的页面
 */
var publicResult = function () {
    return {
        init: function () {

        },
        /**
         * 公共返回,插入到id为insertd的div中
         * @param insertd
         * @param msg
         */
        searchResult: function (insertd, msg) {
            var noResult = '<div class="noResult">' +
                '<div class="layui-row">' +
                '<div class="layui-col-md12 noResultPic">' +
                '</div>' +
                '</div>' +
                '<div class="layui-row">' +
                '<div class="layui-col-md12" >' +
                '<span class="noResultWord">' + msg + '</span>' +
                '</div>' +
                '</div>' +
                '</div>';
            $('#' + insertd).empty();
            $('#' + insertd).append(noResult);
        },
        /**
         * 公共返回,插入到id为insertd的div中
         * @param insertd
         * @param msg
         */
        searchResultError: function (insertd, msg) {
            var noResult = '<div class="noResult">' +
                '<div class="layui-row">' +
                '<div class="layui-col-md12 noResultPic">' +
                '</div>' +
                '</div>' +
                '<div class="layui-row">' +
                '<div class="layui-col-md12" >' +
                '<span class="noResultWord">' + msg + '&nbsp;&nbsp;&nbsp;&nbsp;</span>' +
                '</div>' +
                '</div>' +
                '</div>';
            $('#' + insertd).empty();
            $('#' + insertd).append(noResult);
        },
        initSearchInfo: function (insertd, msg) {
            $(".info-header-div").addClass("hide-search");
            this.searchResult(insertd, msg);
        },
    }
}();
publicResult.init();

/**
 * 公共方法，详细列表滚动控制按钮
 */
var publicDetailedRoll = function () {
    return {
        init: function () {

        },
        /**
         * 公共方法，详细列表滚动控制按钮
         */
        detailedRoll: function () {
            var $this = $("#div_basic_detailed");
            viewH = $this.height();
            contentH = $this.get(0).scrollHeight;
            scrollTop = $this.scrollTop();
            if (0 === scrollTop) {
                $this.scrollTop(contentH - viewH);
                $("#sp_scrollIden").removeClass("icon-icon-109").addClass("icon-icon-108");
            } else {
                $this.scrollTop(0);
                $("#sp_scrollIden").removeClass("icon-icon-108").addClass("icon-icon-109");
                //$("#sp_scrollIden").text("∨");
            }
        },
        /**
         * 公共方法，详细列表滚动控制按钮
         */
        detailedRoll1: function () {
            var $this = $("#tab_clxx");
            viewH = $this.height();
            contentH = $this.get(0).scrollHeight;
            scrollTop = $this.scrollTop();
            if (0 === scrollTop) {
                $this.scrollTop(contentH - viewH);
                $("#sp_scrollIden").removeClass("icon-icon-109").addClass("icon-icon-108");
            } else {
                $this.scrollTop(0);
                $("#sp_scrollIden").removeClass("icon-icon-108").addClass("icon-icon-109");
                //$("#sp_scrollIden").text("∨");
            }
        },
    }
}();
publicDetailedRoll.init();

/**
 * 数据来源组件使用方法：要方法保留
 * 数据来源单选
 *  1.html页面中插入<select class="dataSourceSelect"></select>
 */
var dataSource = function () {
    return {
        init: function () {
            this.getDataSourceObj();
        },
        /**
         * 获取数据来源jQuery对象，并获得ajax数据
         */
        getDataSourceObj: function () {
            var objs = $('.dataSourceSelect');
            if (objs.length > 0) {
                $.ajax({
                    type: 'get',
                    url: dictionary_service_url + 'FindDatailByType/DataSourceLabel',
                    success: function (data) {
                        if (!data) {
                            return;
                        }
                        $.each(objs, function (i, d) {
                            dataSource.joinDataSource(d, data)
                        })
                    }
                });
            }
        },
        /**
         * 数据拼接到select中
         * @param dom 遍历select框的dom对象
         * @param data ajax查询到的数据
         */
        joinDataSource: function (dom, data) {
            layui.use('form', function () {
                var form = layui.form;
                var _html = [];
                _html.push('<option value = "" >全部</option>');
                $.each(data, function (i, d) {
                    _html.push('<option value = "' + d.CODE + '" > ' + d.NAME + '</option>');
                });
                $(dom).append(_html.join(""));
                layui.use(['layer', 'form'], function () {
                    var layer = layui.layer,
                        $ = layui.jquery,
                        form = layui.form;//必须先声明
                    form.render('select');//刷新select渲染
                });
            });
        }
    }
}();
dataSource.init();
/**
 * 专题库-车辆异常徘徊库
 * 数据来源
 * 多选组件
 */
var publicMiltDataSource = function () {
    //标识为要使用号牌种类的公共组件
    var publicMiltDataSource = "public-mulit-data-source";
    //选中项的class
    var checkClass = "layui-form-checked";
    //【全部】选项的class
    var allClass = 'dropdown-checkbox-selectAll';
    //复选框选项html
    var checkBoxHtml = '';
    return {
        init: function () {
            this.getDataSourceObj();
        },

        /**
         * 获取数据来源jQuery对象，并获得ajax数据
         */
        getDataSourceObj: function () {
            $.ajax({
                type: 'get',
                url: dictionary_service_url + 'FindDatailByType/DataSourceLabel',
                success: function (data) {
                    if (!data) {
                        return;
                    }
                    var qt = '';
                    var html = '<div class="layui-row layui-unselect layui-form-checkbox ' + allClass + '" lay-skin="primary" onclick="publicMiltDataSource.selectAll(this)"><span>全部</span><i class="layui-icon"></i></div>';
                    $.each(data, function (i, d) {
                        if (d.NAME == "其他") {
                            qt = '<div class="layui-row layui-unselect layui-form-checkbox" data-value="' + d.CODE + '" onclick="publicMiltDataSource.selectOne(this)" lay-skin="primary"><span>' + d.NAME + '</span><i class="layui-icon"></i></div>';
                        } else {
                            html += '<div class="layui-row layui-unselect layui-form-checkbox" data-value="' + d.CODE + '" onclick="publicMiltDataSource.selectOne(this)" lay-skin="primary"><span>' + d.NAME + '</span><i class="layui-icon"></i></div>';
                        }
                    });
                    html += qt;
                    dropdownCheckbox.init(publicMiltDataSource, html);
                }
            });
        },
        /**
         * 获取已选中的值
         * @param item
         */
        getValue: function (item) {
            var result = [];
            var allChildren = $(item).next().next().children().children();
            $.each(allChildren, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                } else if ($(d).hasClass(checkClass)) {
                    result.push($(d).attr("data-value"));
                }
            });
            $.each(allChildren, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                    if ($(d).hasClass(checkClass)) {
                        result = [];
                    }
                }
            });
            /* if($(item + " ."+allClass).hasClass(checkClass)){
                 result = [];
             }*/
            return result.toString();
        },
        /**
         * 全选
         */
        selectAll: function (item) {
            var selectAll = true;
            if ($(item).hasClass(checkClass)) {
                $(item).removeClass(checkClass);
                selectAll = false;
            } else {
                $(item).addClass(checkClass);
            }

            var nextAll = $(item).nextAll();
            $.each(nextAll, function (i, d) {
                if (selectAll) {
                    $(d).addClass(checkClass);
                } else {
                    $(d).removeClass(checkClass);
                }
            })
            //刷新提示信息
            this.refreshInfo(item);
        },
        /**
         * 选中一个
         */
        selectOne: function (item) {
            if ($(item).hasClass(checkClass)) {
                $(item).removeClass(checkClass);
            } else {
                $(item).addClass(checkClass);
            }
            //全选按钮处理
            var selectCount = publicPlateClassType.getSelectCount(item);
            //选中了【全部】以为的所有选项,则将全选选中，不然则取消全选的选中
            var prevAll = $(item).prevAll();
            $.each(prevAll, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    if (selectCount == $(item).siblings().length) {
                        $(d).addClass(checkClass);
                    } else {
                        $(d).removeClass(checkClass);
                    }
                }
            });
            //刷新提示信息
            this.refreshInfo(item);
        },
        /**
         * 刷新提示信息
         */
        refreshInfo: function (item) {
            var message = '';
            var count = 0;
            //全部选中
            if ($(item).hasClass(allClass) && $(item).hasClass(checkClass)) {
                message = "已全部选中";
            } else {
                var count = this.getSelectCount(item);
            }
            if (count > 0) {
                message = "已选择 " + count + " 项";
            }
            var inputDom = $(item).parents('.dropdown-checkbox-all').children("." + publicMiltDataSource);
            $(inputDom).val(message);
        },
        /**
         * 获取选中了多少个,不包括全部
         * @param item
         */
        getSelectCount: function (item) {
            var count = 0;
            //点击的节点
            if ($(item).hasClass(checkClass)) {
                count++;
            }
            //所有的兄弟节点,不包括全部
            var all = $(item).siblings();
            $.each(all, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                } else if ($(d).hasClass(checkClass)) {
                    count++;
                }
            });
            return count;
        }
    }
}();
publicMiltDataSource.init();
/**
 * 专题库-车辆异常徘徊库
 * 数据来源
 * 多选组件
 */
var publicMiltDataSourceTwo = function () {
    //标识为要使用号牌种类的公共组件
    var publicMiltDataSourceTwo = "public-mulit-data-source-two";
    //选中项的class
    var checkClassTwo = "layui-form-checked-two";
    //【全部】选项的class
    var allClass = 'dropdown-checkbox-selectAll';
    //复选框选项html
    var checkBoxHtml = '';
    return {
        init: function () {
            this.getDataSourceObj();
        },

        /**
         * 获取数据来源jQuery对象，并获得ajax数据
         */
        getDataSourceObj: function () {
            $.ajax({
                type: 'get',
                url: dictionary_service_url + 'FindDatailByType/DataSourceLabel',
                success: function (data) {
                    if (!data) {
                        return;
                    }
                    var qt = '';
                    var html = '<div class="layui-row layui-unselect layui-form-checkbox ' + allClass + '" lay-skin="primary" onclick="publicMiltDataSourceTwo.selectAll(this)"><span>全部</span><i class="layui-icon"></i></div>';
                    $.each(data, function (i, d) {
                        if (d.NAME == '其他') {
                            qt = '<div class="layui-row layui-unselect layui-form-checkbox" data-value="' + d.CODE + '" onclick="publicMiltDataSourceTwo.selectOne(this)" lay-skin="primary"><span>' + d.NAME + '</span><i class="layui-icon"></i></div>';
                        } else {
                            html += '<div class="layui-row layui-unselect layui-form-checkbox" data-value="' + d.CODE + '" onclick="publicMiltDataSourceTwo.selectOne(this)" lay-skin="primary"><span>' + d.NAME + '</span><i class="layui-icon"></i></div>';
                        }
                    });
                    html += qt;
                    dropdownCheckbox.init(publicMiltDataSourceTwo, html);
                }
            });
        },
        /**
         * 获取已选中的值
         * @param item
         */
        getValue: function (item) {
            var result = [];
            var allChildren = $(item).next().next().children().children();
            $.each(allChildren, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                } else if ($(d).hasClass(checkClassTwo)) {
                    result.push($(d).attr("data-value"));
                }
            });

            if ($("." + allClass).hasClass(checkClassTwo)) {
                result = [];
            }
            return result.toString();
        },
        /**
         * 全选
         */
        selectAll: function (item) {
            var selectAll = true;
            if ($(item).hasClass(checkClassTwo)) {
                $(item).removeClass(checkClassTwo);
                selectAll = false;
            } else {
                $(item).addClass(checkClassTwo);
            }

            var nextAll = $(item).nextAll();
            $.each(nextAll, function (i, d) {
                if (selectAll) {
                    $(d).addClass(checkClassTwo);
                } else {
                    $(d).removeClass(checkClassTwo);
                }
            })
            //刷新提示信息
            this.refreshInfo(item);
        },
        /**
         * 选中一个
         */
        selectOne: function (item) {
            if ($(item).hasClass(checkClassTwo)) {
                $(item).removeClass(checkClassTwo);
            } else {
                $(item).addClass(checkClassTwo);
            }
            //全选按钮处理
            var selectCount = publicPlateClassType.getSelectCount(item);
            //选中了【全部】以为的所有选项,则将全选选中，不然则取消全选的选中
            var prevAll = $(item).prevAll();
            $.each(prevAll, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    if (selectCount == $(item).siblings().length) {
                        $(d).addClass(checkClassTwo);
                    } else {
                        $(d).removeClass(checkClassTwo);
                    }
                }
            });
            //刷新提示信息
            this.refreshInfo(item);
        },
        /**
         * 刷新提示信息
         */
        refreshInfo: function (item) {
            var message = '';
            var count = 0;
            //全部选中
            if ($(item).hasClass(allClass) && $(item).hasClass(checkClassTwo)) {
                message = "已全部选中";
            } else {
                var count = this.getSelectCount(item);
            }
            if (count > 0) {
                message = "已选择 " + count + " 项";
            }
            var inputDom = $(item).parents('.dropdown-checkbox-all').children("." + publicMiltDataSourceTwo);
            $(inputDom).val(message);
        },
        /**
         * 获取选中了多少个,不包括全部
         * @param item
         */
        getSelectCount: function (item) {
            var count = 0;
            //点击的节点
            if ($(item).hasClass(checkClassTwo)) {
                count++;
            }
            //所有的兄弟节点,不包括全部
            var all = $(item).siblings();
            $.each(all, function (i, d) {
                if ($(d).hasClass(allClass)) {
                    //点击的是全部
                } else if ($(d).hasClass(checkClassTwo)) {
                    count++;
                }
            });
            return count;
        }
    }
}();
publicMiltDataSourceTwo.init();

/**
 * 车辆异常徘徊==非检测车辆
 * @type {{init, getValue, selectAll, selectOne, refreshInfo, getSelectCount}}
 */
var publicNoCheckVehicleMethod = function () {
    //标识为要使用号牌种类的公共组件
    var classType = "no-check-vehicle";
    //选中项的class
    var checkClass = "layui-form-checked";
    //【全部】选项的class
    var allClass = 'dropdown-checkbox-selectAll';
    //复选框选项html   /*循环  ajax 非检测车辆  */
    //http://15.224.16.131:8001/VIAS/System/Dictionary/FindDatailByType/noCheckVehicle
    var checkBoxHtml = '' +
        '<div class="layui-row">' +
        '<div class="layui-col-md6"><div class="layui-unselect layui-form-checkbox ' + allClass + '" lay-skin="primary" onclick="publicNoCheckVehicleMethod.selectAll(this)"><span>全部</span><i class="layui-icon"></i></div></div>' +
        '<div class="layui-col-md6"><div class="layui-unselect layui-form-checkbox" data-value="02" onclick="publicNoCheckVehicleMethod.selectOne(this)" lay-skin="primary"><span>军车</span><i class="layui-icon"></i></div></div>' +
        '<div class="layui-col-md6"><div class="layui-unselect layui-form-checkbox" data-value="01" onclick="publicNoCheckVehicleMethod.selectOne(this)" lay-skin="primary"><span>警车</span><i class="layui-icon"></i></div></div>' +

        //!!!!!!!!!!!!!!!数据库自动还没有加
        '<div class="layui-col-md6"><div class="layui-unselect layui-form-checkbox" data-value="60" onclick="publicNoCheckVehicleMethod.selectOne(this)" lay-skin="primary"><span>出租车</span><i class="layui-icon"></i></div></div>' +
        '<div class="layui-col-md6"><div class="layui-unselect layui-form-checkbox" data-value="15" onclick="publicNoCheckVehicleMethod.selectOne(this)" lay-skin="primary"><span>公交车</span><i class="layui-icon"></i></div></div>' +
        '<div class="layui-col-md6"><div class="layui-unselect layui-form-checkbox" data-value="37" onclick="publicNoCheckVehicleMethod.selectOne(this)" lay-skin="primary"><span>车</span><i class="layui-icon"></i></div></div>' +
        '</div>' +
        '';
    return {
        init: function () {
            dropdownCheckbox.init(classType, checkBoxHtml);
        },
        /**
         * 获取已选中的值
         * @param item
         */
        getValue: function (item) {
            var result = [];
            var allChildren = $(item).next().next().children().children().children();
            $.each(allChildren, function (i, d) {
                if ($($(d)[0].children[0]).hasClass(allClass)) {
                    //点击的是全部
                } else if ($($(d)[0].children[0]).hasClass(checkClass)) {
                    result.push($($(d)[0].children[0]).attr("data-value"));
                }
            })
            return result.toString();
        },
        /**
         * 全选
         */
        selectAll: function (item) {
            var selectAll = true;
            if ($(item).hasClass(checkClass)) {
                $(item).removeClass(checkClass);
                selectAll = false;
            } else {
                $(item).addClass(checkClass);
            }
            //.parent().siblings();
            var nextAll = $(item).parent().nextAll();
            $.each(nextAll, function (i, d) {

                if (selectAll) {
                    $($(d)[0].children[0]).addClass(checkClass);
                } else {
                    $($(d)[0].children[0]).removeClass(checkClass);
                }
            })
            //刷新提示信息
            publicNoCheckVehicleMethod.refreshInfo(item);
        },
        /**
         * 选中一个
         */
        selectOne: function (item) {
            if ($(item).hasClass(checkClass)) {
                $(item).removeClass(checkClass);
            } else {
                $(item).addClass(checkClass);
            }
            //全选按钮处理
            var selectCount = publicNoCheckVehicleMethod.getSelectCount(item);
            //选中了【全部】以为的所有选项,则将全选选中，不然则取消全选的选中
            var prevAll = $(item).parent().prevAll();
            $.each(prevAll, function (i, d) {
                if ($($(d)[0].children[0]).hasClass(allClass)) {
                    if (selectCount == $(item).parent().siblings().length) {
                        $($(d)[0].children[0]).addClass(checkClass);
                    } else {
                        $($(d)[0].children[0]).removeClass(checkClass);
                    }
                }
            })
            //刷新提示信息
            publicNoCheckVehicleMethod.refreshInfo(item);
        },
        /**
         * 刷新提示信息
         */
        refreshInfo: function (item) {
            var message = '';
            var count = 0;
            //全部选中
            if ($(item).hasClass(allClass) && $(item).hasClass(checkClass)) {
                message = "已全部选中";
            } else {
                count = publicNoCheckVehicleMethod.getSelectCount(item);
            }
            if (count > 0) {
                message = "已选择 " + count + " 项";
            }
            var inputDom = $(item).parents('.dropdown-checkbox-all').children("." + classType);
            $(inputDom).val(message);
        },
        /**
         * 获取选中了多少个,不包括全部
         * @param item
         */
        getSelectCount: function (item) {
            var count = 0;
            //点击的节点
            if ($(item).hasClass(checkClass)) {
                count++;
            }
            //所有的兄弟节点,不包括全部
            var all = $(item).parent().siblings();

            $.each(all, function (i, d) {
                var span_class = $($(d)[0].children[0])
                if (span_class.hasClass(allClass)) {
                    //点击的是全部
                } else if (span_class.hasClass(checkClass)) {
                    count++;
                }
            });
            return count;
        }
    }
}();
publicNoCheckVehicleMethod.init();
/**
 * 主驾驶-副驾驶
 */
var publicGetDriverPic = function () {
    return {
        getPicUrl: function (ssid) {
            var picUrl = {
                'ZJSSID': '',
                'FJSSID': ''
            };;
            $.ajax({
                url: common_driver_face_picInfo,
                type: "get",
                dataType: "json",
                data: {
                    ssId: ssid
                },
                success: function (data) {
                    $.each(picUrl, function (i, d) {
                        picUrl.i = data.i
                    });
                }
            });
            return picUrl;
        }
    }
}();
/**
 * 技战法的接口公共方法
 */
var publicTechnicaltacticsInterfac = function () {
    return {
        init: function () {
        },
        noOperationCallBck: function () {

        },
        /**
         * 获取号牌颜色
         * @param plateColorParam
         */
        getPlateColor: function (plateColorParam) {
            var param = plateColorParam.split(",");
            $.each($('#numcolor').children('span'), function (i, d) {
                $.each(param, function (m, n) {
                    if ($(d).attr("code") == n) {
                        $(d).attr("spanflag", true);
                        $(d).css("box-shadow", "0 0 0 2px red");
                    }
                });
            });
        },
        /**
         * 获取车身颜色
         * @param vehicleColor
         */
        getVehicleColor: function (vehicleColorParam) {
            var param = vehicleColorParam.split(",");
            $.each($('#carcolor').children('span'), function (i, d) {
                $.each(param, function (m, n) {
                    if ($(d).attr("code") == n) {
                        $(d).attr("spanflag", true);
                        $(d).find("i").css('visibility', 'visible');
                    }
                });
            });
        },
        
        /**
         * 获取号牌号码
         * @param plateNoParam
         */
        getPlateNo: function (plateNoParam) {
            var platenoTemp = decodeURIComponent(plateNoParam);
            if (platenoTemp != "" && platenoTemp != undefined) {
                $('#plateno_suffix').val(platenoTemp);
            }
        },
        /**
         * 获取数据来源
         * @param ssPlatformIdentParem
         */
        getSsPlatformIdent: function (ssPlatformIdentParem) {
            var ssPlatformIdent = ssPlatformIdentParem != "" ? ssPlatformIdentParem.split(",") : [];
            //设备
            if (ssPlatformIdent.length > 0) {
                var info = '已选择' + ssPlatformIdent.length + '项';
                $(".public-mulit-data-source").val(info);
                $(".public-mulit-data-source-two").val(info);
            }
            var allChildren = $(".mulitDataSource .public-mulit-data-source").next().next().children().children();
            var allChildrenTwo = $(".mulitDataSource .public-mulit-data-source-two").next().next().children().children();
            if (allChildren.length != 0) {
                $.each(allChildren, function (i, d) {
                    $.each(ssPlatformIdent, function (m, n) {
                        if ($(d).attr("data-value") == n) {
                            $(d).addClass("layui-form-checked");
                        }
                    });
                });
                // var info = '已选择' + ssPlatformIdent.length + '项';
                // $(".public-mulit-data-source").val(info);
            } else {
                $.each(allChildrenTwo, function (i, d) {
                    $.each(ssPlatformIdent, function (m, n) {
                        if ($(d).attr("data-value") == n) {
                            $(d).addClass("layui-form-checked-two");
                        }
                    });
                });
                // var info = '已选择' + ssPlatformIdent.length + '项';
                // $(".public-mulit-data-source-two").val(info);
            }
        },
        /**
         * 车辆类型
         *  vehicleclasscheck
         */
        getVehicleClass: function (vehicleClassParam) {
            var param = vehicleClassParam != "" ? vehicleClassParam.split(",") : [];
            $.each($('#vehicleclasscheck').children('.eachspan'), function (i, d) {
                $.each(param, function (m, n) {
                    if ($(d).attr("data-code") == n) {
                        $(d).attr("spanflag", true);
                        $(d).addClass("layui-form-checked");
                    }
                });
            });
        },
        /**
         * 号牌种类
         * plateClass
         */
        getPlateClass: function (plateClassParem) {
            var ssPlatformIdent = plateClassParem != "" ? plateClassParem.split(",") : [];
            //设备
            if (ssPlatformIdent.length > 0) {
                var info = '已选择' + ssPlatformIdent.length + '项';
                $(".public-plate-class-type").val(info);
            }
            var allChildren = $(".public-plate-class-type").next().next().children().children();
            $.each(allChildren, function (i, d) {
                $.each(ssPlatformIdent, function (m, n) {
                    if ($(d).attr("data-value") == n) {
                        $(d).addClass("layui-form-checked");
                    }
                });
            });
        },
        /**
         * 套牌车
         *  deck_type
         */
        getDeckType: function (deckTypeParam) {
            var ssPlatformIdent = deckTypeParam != "" ? deckTypeParam.split(",") : [];
            //设备
            if (ssPlatformIdent.length > 0) {
                var info = '已选择' + ssPlatformIdent.length + '项';
                $(".public-copy-plate").val(info);
            }
            var allChildren = $(".public-copy-plate").next().next().children().children();
            $.each(allChildren, function (i, d) {
                $.each(ssPlatformIdent, function (m, n) {
                    if ($(d).attr("data-value") == n) {
                        $(d).addClass("layui-form-checked");
                    }
                });
            });
        },
        /**
         * 阈值 活动范围等
         * @param threshoIdParam
         * @param silderClass
          * @param silderId
         */
        getThreshoId: function (threshoIdParam, silderClass, silderId) {
            $(silderId).slider({
                value: threshoIdParam,
                min: 1,
                slide: function (event, ui) {
                    $(silderClass).text(ui.value);
                    $(event.target.lastChild).children().text(ui.value);
                }
            });
            $(silderClass).text($(silderId).slider('value'));
        },
        /**
         * 获取页面一个设备的情况
         * @param apeParam
         */
        getDeviceId: function (apeParam, id) {
            var deviceId = apeParam != "" ? apeParam.split(",") : [];
            //设备
            if (deviceId.length > 0) {
                var info = '共选了' + deviceId.length + '个设备';
                $(".choiseApe").addClass("hide-search");
                $(".delChoseApe").removeClass("hide-search");
                $("#" + id).val(info);
            }
        },
        /**
         * 获取页面两个设备的情况
         * @param apeParam
         */
        getDoubleDeviceId: function (apeParam, flag, id) {
            var deviceId = apeParam != "" ? apeParam.split(",") : [];
            //设备
            if (flag == 0) {
                if (deviceId.length > 0) {
                    var _msg = '共选了' + deviceId.length + '个设备';
                    $(".delChoseApe_one").removeClass("hide-search");
                    $(".choiseApe_one").addClass("hide-search");
                    $(id).val(_msg);
                }
            } else {
                if (deviceId.length > 0) {
                    var _msg = '共选了' + deviceId.length + '个设备';
                    $(".delChoseApe_two").removeClass("hide-search");
                    $(".choiseApe_two").addClass("hide-search");
                    $(id).val(_msg);
                }
            }
        },
    }
}();
publicTechnicaltacticsInterfac.init();
